from django.shortcuts import render,HttpResponse
from . import ana
# Create your views here.
REMOTE_HOST = "https://pyecharts.github.io/assets/js"
def index(request):
    return render(request,'first/base.html')
def index1(request):
    context={
        'liushui':ana.UsersAna_obj.get_total_sales(),
        'most':ana.UsersAna_obj.get_most_trade_num(),
        'mostmoney':ana.UsersAna_obj.get_most_many_money(),
        'chicken':ana.UsersAna_obj.get_Chicken_Bowl_most_desc(),
    }
    return render(request,'first/hao.html',context)
def get_pie_every_trade(request):
    bar=ana.UsersAna_obj.make_pie_every_trade()
    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'first/index.html', context)
def get_pie_chicken_bowl(request):
    bar = ana.UsersAna_obj.make_pie_Chicken_Bowl_every()
    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'first/index.html', context)
def get_bar__eveny_order_sum(request):
    bar = ana.UsersAna_obj.make_eveny_order_sum()
    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'first/index.html', context)
    # return render(request, 'first/hao.html', context)


def get_bar_every_sale_money(request):

    bar = ana.UsersAna_obj.make_every_sale_money()
    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    return render(request, 'first/index.html', context)


def get_bar_every__sale_num(request):
    bar = ana.UsersAna_obj.make_every_sale_num()
    bar2=ana.UsersAna_obj.make_every_sale_money()
    context = dict(

        myechart=bar.render_embed(),
        myechart2=bar2.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()
    )

    # return render(request, 'first/hao.html', context)
    # return render(request, 'first/index.html', context)
    return render(request, 'first/map.html', context)
def get_table_price_choice(request):
    info=ana.UsersAna_obj.make_table_every_trade_choice()
    context={
        'info':info,
        'type':'产品的种类及对应的商品配料的价格',
    }
    return render(request,'first/table1.html',context)
